package com.business.controller.interfaced;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.alipay.util.AliPayUtil;
import com.business.service.interfaced.impl.HighEntertainInService;
import com.honour.service.interfaced.ServerInManager;
import com.honour.service.interfaced.SortInManager;
import com.system.common.OrderEnum;
import com.system.controller.base.BaseController;
import com.system.util.AppUtil;
import com.system.util.Const;
import com.system.util.FTPUtils;
import com.system.util.NetworkUtil;
import com.system.util.PageData;
import com.system.util.Tools;
import com.system.util.ToolsUtil;
import com.system.util.UpdImgUtils;
import com.wxpay.util.WXPayUtil;

/**
 * 荣耀特权管理接口
 * @Function 
 * @Author zhaozhenhua
 * @Date 2018年4月13日
 */

@Controller
@RequestMapping("/highsort")
public class HighEntertainInController extends BaseController{
	
	@Resource(name="highEntertainInService")
	private HighEntertainInService highEntertainInService;
	
	@Resource(name="serverinService")
	private ServerInManager serverinService;
	
	@Resource(name="sortinService")
	private SortInManager sortinService;
	
	/**
	 * 后台获取荣耀特权店铺详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月13日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getshopdet")
	@ResponseBody
	public Object getShopDet(){
		logBefore(logger, "后台获取荣耀特权店铺详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETSHOPDET", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getShopInfo", pd)){	//检查参数
				   PageData shopDet = new PageData();
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HORSE)){   //入驻分类为马术商家
					   shopDet = highEntertainInService.getHorseDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_YACHT)){   //入驻分类为游艇
					   shopDet = highEntertainInService.getYachtDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_LUXCAR)){   //入驻分类为豪车
					   shopDet = highEntertainInService.getLuxCarDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_GOLF)){   //入驻分类为高尔夫
					   shopDet = highEntertainInService.getGolfDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_PLANE)){   //入驻分类为飞机
					   shopDet = highEntertainInService.getPlaneDetById(pd);
				   }
				   if(shopDet!=null){
					   ToolsUtil.putImgstoArray(shopDet, "DETIMGS");
				   }
				   map.put("shop", shopDet);
				   result = (null==shopDet)?"02": "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 后台获取荣耀特权店铺信息
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月13日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getshopinfo")
	@ResponseBody
	public Object getShopInfo(){
		logBefore(logger, "后台获取荣耀特权店铺信息");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETSHOPINFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getShopInfo", pd)){	//检查参数
				   PageData shop = new PageData();
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HORSE)){   //入驻分类为马术商家
					   shop = highEntertainInService.getHorseShopById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_YACHT)){   //入驻分类为游艇
					   shop = highEntertainInService.getYachtShopById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_LUXCAR)){   //入驻分类为豪车
					   shop = highEntertainInService.getLuxCarShopById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_GOLF)){   //入驻分类为高尔夫
					   shop = highEntertainInService.getGolfShopById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_PLANE)){   //入驻分类为飞机
					   shop = highEntertainInService.getPlaneShopById(pd);
				   }
				   
				   map.put("shop", shop);
				   result = (null==shop)?"02": "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 后台修改荣耀特权店铺信息
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月13日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="updshopinfo")
	@ResponseBody
	public Object updShopInfo(MultipartHttpServletRequest mreq,HttpServletResponse resp,HttpServletRequest request,String CATEGORY_ID
			,String SORTHIGH_ID,String PRICE,String PHONE){
		logBefore(logger, "后台修改荣耀特权店铺信息");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		String SHOWIMAGES="";
		System.out.println("CATEGORY_ID:"+pd.getString("CATEGORY_ID"));
		System.out.println("SORTHIGH_ID:"+pd.getString("SORTHIGH_ID"));
		pd.put("CATEGORY_ID", CATEGORY_ID);
		pd.put("SORTHIGH_ID", SORTHIGH_ID);
		pd.put("PRICE", PRICE);
		pd.put("PHONE", PHONE);
		try{
			if(Tools.checkKey("UPDSHOPINFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getShopInfo", pd)){	//检查参数
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HORSE)){   //入驻分类为马术商家
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getHorseShopById(pd);
							SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "businessimgs/shopimgs");
							pd.put("SHOWIMAGES", SHOWIMAGES);
							UpdImgUtils.delImgMethod(p, "SHOWIMAGES", "businessimgs/shopimgs");
						}
					   highEntertainInService.updHorseInfoById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_YACHT)){   //入驻分类为游艇
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getYachtShopById(pd);
							SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "businessimgs/shopimgs");
							pd.put("SHOWIMAGES", SHOWIMAGES);
							UpdImgUtils.delImgMethod(p, "SHOWIMAGES", "businessimgs/shopimgs");
						}
					   highEntertainInService.updYachtInfoById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_LUXCAR)){   //入驻分类为豪车
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getLuxCarShopById(pd);
							SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "businessimgs/shopimgs");
							pd.put("SHOWIMAGES", SHOWIMAGES);
							UpdImgUtils.delImgMethod(p, "SHOWIMAGES", "businessimgs/shopimgs");
						}
					   highEntertainInService.updLuxcarInfoById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_GOLF)){   //入驻分类为高尔夫
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getGolfShopById(pd);
							SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "businessimgs/shopimgs");
							pd.put("SHOWIMAGES", SHOWIMAGES);
						    UpdImgUtils.delImgMethod(p, "SHOWIMAGES", "businessimgs/shopimgs");
						}
					   highEntertainInService.updGolfInfoById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_PLANE)){   //入驻分类为飞机
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getPlaneShopById(pd);
							SHOWIMAGES = FTPUtils.upSingleImg(mreq, "SHOWIMAGES", "businessimgs/shopimgs");
							pd.put("SHOWIMAGES", SHOWIMAGES);
							UpdImgUtils.delImgMethod(p, "SHOWIMAGES", "businessimgs/shopimgs");
						}
					   highEntertainInService.updPlaneInfoById(pd);
				   }
				   result = "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/***
	 * 后台修改荣耀特权店铺详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月14日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="updshopdet")
	@ResponseBody
	public Object updShopDet(MultipartHttpServletRequest mreq,HttpServletResponse resp,HttpServletRequest request,String CATEGORY_ID
			,String SORTHIGH_ID,String DETINTRO
			,String PUPINTROTITLE,String PUPINTROCONTENT
			,String PDOWNINTROTITLE,String PDOWNINTROCONTENT
			){
		logBefore(logger, "后台修改荣耀特权店铺详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		pd.put("CATEGORY_ID", CATEGORY_ID);
		pd.put("SORTHIGH_ID", SORTHIGH_ID);
		pd.put("DETINTRO", DETINTRO);
		pd.put("PUPINTROTITLE", PUPINTROTITLE);
		pd.put("PDOWNINTROTITLE", PDOWNINTROTITLE);
		pd.put("PUPINTROTITLE", PUPINTROTITLE);
		pd.put("PUPINTROTITLE", PUPINTROTITLE);
		String DETIMGS="";
		try{
			if(Tools.checkKey("UPDSHOPINFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				//检查参数
				//if(AppUtil.checkParam("getShopInfo", pd)){	
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HORSE)){   //入驻分类为马术商家
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getHorseDetById(pd);
							DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/horseshopimgs/horsedetimgs");
						    UpdImgUtils.delImgMethod(p, "DETIMGS", "highsortimgs/horseshopimgs/horsedetimgs");
						    pd.put("DETIMGS", DETIMGS);
						}
					   highEntertainInService.updHorseDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_YACHT)){   //入驻分类为游艇
						PageData p = highEntertainInService.getYachtDetById(pd);
						DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/yachtshopimgs/yachtdetimgs");
					    UpdImgUtils.delImgMethod(p, "DETIMGS", "highsortimgs/yachtshopimgs/yachtdetimgs");
					    pd.put("DETIMGS", DETIMGS);
					    highEntertainInService.updYachtDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_LUXCAR)){   //入驻分类为豪车
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getLuxCarDetById(pd);
							DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/luxcarshopimgs/luxcardetimgs");
						    UpdImgUtils.delImgMethod(p, "DETIMGS", "highsortimgs/luxcarshopimgs/luxcardetimgs");
						    pd.put("DETIMGS", DETIMGS);
						}
					   highEntertainInService.updLuxcarDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_GOLF)){   //入驻分类为高尔夫
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getGolfDetById(pd);
							DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/golfshopimgs/golfdetimgs");
						    UpdImgUtils.delImgMethod(p, "DETIMGS", "highsortimgs/golfshopimgs/golfdetimgs");
						    pd.put("DETIMGS", DETIMGS);
						}
					   highEntertainInService.updGolfDetById(pd);
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_PLANE)){   //入驻分类为飞机
					   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						else{
							PageData p = highEntertainInService.getPlaneDetById(pd);
							DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/planeshopimgs/planedetimgs");
						    UpdImgUtils.delImgMethod(p, "DETIMGS", "highsortimgs/planeshopimgs/planedetimgs");
						    pd.put("DETIMGS", DETIMGS);
						}
					   highEntertainInService.updPlaneDetById(pd);
				   }
				   result = "01";
				   /*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 获取游艇等处的按钮信息
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月21日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getbuttoninfo")
	@ResponseBody
	public Object getButtonInfo(){
		logBefore(logger, "获取游艇等处的按钮信息");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETBUTTONINFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getButtonInfo", pd)){	//检查参数
				   PageData info = serverinService.getButtonInfo(pd);
				   map.put("pd", info);
				   result = (null==info)?"02": "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 获取游艇等处的按钮
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月23日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="getbuttonlist")
	@ResponseBody
	public Object getButtonList(){
		logBefore(logger, "获取游艇等处的按钮");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		try{
			if(Tools.checkKey("GETBUTTONLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getButtonList", pd)){	//检查参数
					   List<PageData> list = serverinService.getButtonList(pd);
					   map.put("pd", list);
					   result = (null==list||list.size()==0)?"02": "01";
					}else {
						result = "03";
					}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 后台添加荣耀特权店铺详情
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月23日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="addshopdet")
	@ResponseBody
	public Object addShopDet(MultipartHttpServletRequest mreq,HttpServletResponse resp,HttpServletRequest request,String CATEGORY_ID
			,String DETINTRO,String SHOP_ID
			,String PUPINTROTITLE,String PUPINTROCONTENT
			,String PDOWNINTROTITLE,String PDOWNINTROCONTENT
			){
		logBefore(logger, "后台添加荣耀特权店铺详情");
		Map<String , Object>map=new HashMap<String, Object>();
		PageData pd=new PageData();
		pd=this.getPageData();
		String result="00";
		pd.put("CATEGORY_ID", CATEGORY_ID);
		pd.put("DET_ID", this.getSnowId());
		pd.put("SHOP_ID", SHOP_ID);
		pd.put("DETINTRO", DETINTRO);
		pd.put("PUPINTROTITLE", PUPINTROTITLE);
		pd.put("PDOWNINTROTITLE", PDOWNINTROTITLE);
		pd.put("PUPINTROTITLE", PUPINTROTITLE);
		pd.put("PUPINTROTITLE", PUPINTROTITLE);
		String DETIMGS="";
		try{
			if(Tools.checkKey("ADDSHOPDET", pd.getString("FKEY"))){	//检验请求key值是否合法
				//检查参数
				//if(AppUtil.checkParam("getShopInfo", pd)){	
				   if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_HORSE)){   //入驻分类为马术商家
					   PageData p = highEntertainInService.getHorseDetById(pd);
					   if(p==null){
						   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						   else{
							   DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/horseshopimgs/horsedetimgs");
							   pd.put("DETIMGS", DETIMGS);
						   }
						   highEntertainInService.addHorseDet(pd);
					   }else{
						   map.put("msg", "请不要重复添加");
						   return AppUtil.returnObject(new PageData(), map); 
					   }
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_YACHT)){   //入驻分类为游艇
						PageData p = highEntertainInService.getYachtDetById(pd);
						if(p==null){
							DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/yachtshopimgs/yachtdetimgs");
							pd.put("DETIMGS", DETIMGS);
							highEntertainInService.updYachtDetById(pd);
						}
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_LUXCAR)){   //入驻分类为豪车
					   PageData p = highEntertainInService.getLuxCarDetById(pd);
					   if(p==null){
						   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						   else{
							   DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/luxcarshopimgs/luxcardetimgs");
							   pd.put("DETIMGS", DETIMGS);
						   }
						   highEntertainInService.updLuxcarDetById(pd);
					   }else{
						   map.put("msg", "请不要重复添加");
						   return AppUtil.returnObject(new PageData(), map); 
					   }
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_GOLF)){   //入驻分类为高尔夫
					   PageData p = highEntertainInService.getGolfDetById(pd);
					   if(p==null){
						   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						   else{
							   DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/golfshopimgs/golfdetimgs");
							   pd.put("DETIMGS", DETIMGS);
						   }
						   highEntertainInService.updGolfDetById(pd);
					   }else{
						   map.put("msg", "请不要重复添加");
						   return AppUtil.returnObject(new PageData(), map); 
					   }
				   } if(pd.getString("CATEGORY_ID").equals(Const.BUSINESS_PLANE)){   //入驻分类为飞机
					   PageData p = highEntertainInService.getPlaneDetById(pd);
					   if(p==null){
						   if(mreq.getFileMap()==null||mreq.getFileMap().size()==0){}
						   else{
							   DETIMGS = FTPUtils.upMultiImgs(mreq, resp, "DETIMGS", "highsortimgs/planeshopimgs/planedetimgs");
							   pd.put("DETIMGS", DETIMGS);
						   }
						   highEntertainInService.updPlaneDetById(pd);
					   }else{
						   map.put("msg", "请不要重复添加");
						   return AppUtil.returnObject(new PageData(), map); 
					   }
				   }
				   result = "01";
				   /*}else {
					result = "03";
				}*/
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 高端特权生成订单
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月27日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="/addhighorder")
	@ResponseBody
	public Object addHighOrder(){
		logBefore(logger, "高端特权生成订单");
		Map<String,Object> map = new HashMap<String,Object>();
		PageData pd = new PageData();
		pd = this.getPageData();		
		String result = "00";
		PageData po = new PageData();
		try{
			if(Tools.checkKey("ADDHIGHORDER", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("addHighOrder", pd)){	//检查参数
					String HIGHENTERORDER_ID = this.getSnowId();
					pd.put("HIGHENTERORDER_ID", HIGHENTERORDER_ID);
					//调用工具类生成订单号
					String getnum = ToolsUtil.GetHotelOrderID(pd.getString("HONOURUSER_ID"));
					pd.put("ORDERNUMBER",getnum);
					pd.put("ORDERTIME", ToolsUtil.getStringDate());
					//订单状态改为待付款
					pd.put("ORDERSTATUS", "0040001");
					//添加相对应的酒店订单
					highEntertainInService.addHighOrder(pd);
					//添加相对应的用户订单中间信息
					po.put("USERORDER_ID", this.getSnowId());
					po.put("ORDERTYPE", pd.getString("ORDERTYPE"));  
					po.put("HONOURUSER_ID", pd.getString("HONOURUSER_ID"));
					po.put("SORTTYPE_ID", pd.get("SHOP_ID"));
					sortinService.addUserOrder(po);
					
					//调用支付宝或微信接口生成支付信息
					String orderStr = "";
					switch (pd.getString("PAYTYPE")) {
					case "支付宝":
						orderStr = AliPayUtil.aliPay(pd);
						map.put("PAYTYPE", "支付宝");
						map.put("orderStr", orderStr);
						break;
					case "微信":
						pd.put("spbillCreateIp", NetworkUtil.getIPAddress(getRequest()));
						SortedMap<String, Object> weixinPrePay = WXPayUtil.weixinPrePay(pd);
						map.put("orderStr", weixinPrePay);
						map.put("PAYTYPE", "微信");
						break;
						
					default:
						break;
					}
					//返回01为创建成功并返回
					map.put("ORDERNUMBER", getnum);
					result =  "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 后台查询高端特权订单列表
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月27日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="/gethighorders")
	@ResponseBody
	public Object getHighOrders(){
		logBefore(logger, "后台查询高端特权订单列表");
		Map<String,Object> map = new HashMap<String,Object>();
		PageData pd = new PageData();
		pd = this.getPageData();		
		String result = "00";
		try{
			if(Tools.checkKey("GETHIGHORDERS", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getOrderNumAndMoney", pd)){	//检查参数
					List<PageData> list = highEntertainInService.getHighOrders(pd);
					map.put("pd", list);
					result = (Tools.isEmptyList(list)) ? "02" : "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 后台统计高端特权订单数量
	  * @Description
	  * @Author zhaozhenhua
	  * @date   2018年4月27日
	  * @param pd
	  * @return
	  * @throws Exception
	 */
	@RequestMapping(value="/gethighordercount")
	@ResponseBody
	public Object getHighOrderCount(){
		logBefore(logger, "后台查询高端特权订单列表");
		Map<String,Object> map = new HashMap<String,Object>();
		PageData pd = new PageData();
		pd = this.getPageData();		
		String result = "00";
		try{
			if(Tools.checkKey("GETHIGHORDERCOUNT", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getCouponListById", pd)){	//检查参数
					//订单状态（0040001）为待付款状态， (0040002) 为待使用状态， (0040003) 为待评价状态， (0040004) 为已完成订单状态
					pd.put("ORDERSTATUS", OrderEnum.NOPAY.getCode());
					int no_pay_count = highEntertainInService.getHighOrderCount(pd);
					pd.put("ORDERSTATUS", OrderEnum.WAIT_USE.getCode());
					int wait_user_count = highEntertainInService.getHighOrderCount(pd);
					pd.put("ORDERSTATUS", OrderEnum.WAIT_EVLU.getCode());
					int wait_evlu_count = highEntertainInService.getHighOrderCount(pd);
					pd.put("ORDERSTATUS", OrderEnum.FINISH.getCode());
					int finish_count = highEntertainInService.getHighOrderCount(pd);
					map.put("no_pay_count", no_pay_count);
					map.put("wait_user_count", wait_user_count);
					map.put("wait_evlu_count", wait_evlu_count);
					map.put("finish_count", finish_count);
					result =  "01";
				}else {
					result = "03";
				}
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	

}
